package com.example.parse_springboot.entity;

public class Result<T> {
    int code;
    String message;
    T data;

    public Result(int code) {
        this.code = code;
    }

    public Result(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public Result(String message) {
        this.message = message;
    }

    public static Result<String> success() {
        return new Result<String>(200);
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(200, data);
    }

    public static Result<String> error() {
        return new Result<String>(0);
    }

    public static Result<String> error(String message) {
        return new Result<String>(message);
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
